import abc

import numpy as np


class CanonicalSystem(abc.ABC):
    def __init__(self, alpha=1.0) -> None:
        super().__init__()
        self._x = 1.0
        self._alpha = alpha
        self._dt = 0.0

        self._run_time = 0.0
        self._timesteps = 0
        self._time = 0.0

    @property
    def alpha(self):
        return self._alpha

    @property
    def run_time(self):
        return self._run_time

    @property
    def timesteps(self):
        return self._timesteps

    @property
    def dt(self):
        return self._dt

    @dt.setter
    def dt(self, dt: float):
        self._dt = dt
        self._init_timesteps()

    def _init_timesteps(self):
        self._timesteps = round(self._run_time / self._dt) + 1

    def reset(self):
        self._x = 1.0
        self._time = 0.0

    def run(self, tau=1.0) -> np.ndarray:
        timesteps = round(self._timesteps / tau)

        self.reset()
        x_track = np.zeros(timesteps)

        for t in range(timesteps):
            x_track[t] = self._x
            self.step(tau)
        x_track[-1] = self._x

        return x_track

    def step(self, tau: float) -> float:
        pass

    def interpolate(self, t: float) -> float:
        pass
